/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package hhf.worldzones.daos;

import hhf.worldzones.entities.Continent;
import hhf.worldzones.entities.Country;
import javax.ejb.Asynchronous;
import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;

/**
 *
 * @author François
 */
@Stateless
public class CountryDAO extends ZoneDAO<Country> {
	public CountryDAO() {
		super(Country.class);
	}

	@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
	@Asynchronous
	public void createCountry(String countryKey, String label, Continent continent, Integer latitude, Integer longitude) {
		if (!contains(countryKey)) {
			Country country = new Country();
			country.setCode(countryKey);
			country.setLabel(label);
			country.setContinent(continent);
			country.setLatitude(latitude);
			country.setLongitude(longitude);
			persist(country);
		}
	}
	
}
